import React, { useContext } from 'react'
import {CounterContext} from '../context/CounterProvider'

const Action = () => {
    const { count,setCount } = useContext(CounterContext);
    const handleAdd = () => {
        setCount(count + 1);
    }
    const handleSub = () => {
        setCount(count - 1);
    }
    return (
        <div>
            <button onClick={handleAdd}>加1</button>
            <button onClick={handleSub}>减1</button>
        </div>
    )
}

export default Action